class MyDebugPDO extends DebugPDO {
  
  public function prepare($sql, $driver_options = array())
  {
    $startTimeSec = microtime(true);
    $res = parent::prepare($sql, $driver_options);
    $endTimeSec = microtime(true);
    $executionTimeMs = number_format(($endTimeSec - $startTimeSec) * 1000,3);    
    
    $this->log('prepare: ['.$executionTimeMs.' ms] ' . $sql);
    
    return $res;
  }  
  
  public function exec($sql)
  {
    $startTimeSec = microtime(true);
    $res = parent::exec($sql);
    $endTimeSec = microtime(true);
    $executionTimeMs = number_format(($endTimeSec - $startTimeSec) * 1000,3);
    
    $this->log('exec: ['.$executionTimeMs.' ms] ' . $sql);
    $this->incrementQueryCount();
    
    return $res;
  }


  public function query()
  {
    $args = func_get_args();
    
    
    $startTimeSec = microtime(true);
    $res = call_user_func_array(array($this, 'parent::query'), $args);
    $endTimeSec = microtime(true);
    $executionTimeMs = number_format(($endTimeSec - $startTimeSec) * 1000,3);
    
    $this->log('query: ['.$executionTimeMs.' ms] ' . $args[0]);
    $this->incrementQueryCount();
    
    return $res;
  }  
  
}
